<template>
  <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="700px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
      <el-form-item label="标签类型" prop="tagType">
        <el-select v-model="form.tagType" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.type_org_tag" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item label="标签分组">
        <org-tag-group-suggest v-model="form.tagGroup" :name="form.tagGroup" placeholder="请选择" />
      </el-form-item>
      <el-form-item label="标签值">
        <el-input v-model="form.tagValue" />
      </el-form-item>
      <el-form-item label="区域ID">
        <region-tree v-model="form.regionId" placeholder="请选择区域" :node-key="form.regionId" />
      </el-form-item>
      <el-form-item label="组织ID">
        <org-tree v-model="form.orgId" placeholder="请选择组织" :node-key="form.orgId" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="crud.cancelCU">取消</el-button>
      <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { form } from '@crud/crud'
import OrgTagGroupSuggest from '@/views/business/common/org/components/TagGroupSuggest/index'
import RegionTree from '@/views/business/common/org/components/RegionTree/index'
import OrgTree from '@/views/business/common/org/components/OrgTree/index'

const defaultForm = { id: null, tagType: null, tagGroup: null, tagValue: null, regionId: null, orgId: null }
export default {
  components: { OrgTree, RegionTree, OrgTagGroupSuggest },
  mixins: [form(defaultForm)],
  props: {
    dict: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      rules: {
        tagType: [{ required: true, message: '标签类型不能为空', trigger: 'blur' }]
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
